﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SRF.Data
{
    /// <summary>
    /// 查询接口
    /// </summary>
    public interface IQuery
    {
        /// <summary>
        /// 设置参数
        /// </summary>
        /// <param name="paraName">参数名</param>
        /// <param name="obj">参数值</param>
        /// <returns></returns>
        IQuery SetParameter(string paraName, object obj);
        /// <summary>
        /// 参数 用集合类型或对象
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        IQuery SetParameter(object obj);
        /// <summary>
        /// 设置查询分页
        /// </summary>
        /// <param name="startRow">开始行（从1开始）</param>
        /// <param name="maxRows">最大行数</param>
        /// <returns></returns>
        IQuery SetLimit(int startRow, int maxRows);
        /// <summary>
        /// 设置排序，如“order by name desc”
        /// </summary>
        /// <param name="orderBy"></param>
        /// <returns></returns>
        IQuery SetOrderBy(string orderBy);
        /// <summary>
        /// 执行
        /// </summary>
        /// <returns>返回影响行数</returns>
        int Execute();
        /// <summary>
        /// 查询，返回实体类型
        /// </summary>
        /// <typeparam name="T">实体类型</typeparam>
        /// <returns></returns>
        IList<T> List<T>();
        /// <summary>
        /// 查询 返回datareader
        /// </summary>
        /// <returns></returns>
        System.Data.IDataReader DataReader();
        /// <summary>
        /// 查询 返回dataset
        /// </summary>
        /// <returns></returns>
        System.Data.DataSet DataSet();
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        object UniqueResult();
        /// <summary>
        /// 查询分会实体 
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        T UniqueResult<T>();
        /// <summary>
        /// 记录是否存在
        /// </summary>
        /// <returns>返回记录是否存在</returns>
        bool Exists(); 
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        IDictionary<string, object> Dictionary();
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        IList<IDictionary<string, object>> Dictionarys();
        /// <summary>
        /// 参数列表
        /// </summary>
        IDictionary<string, object> Parameters
        {
            get;
        }
    }
}